#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/11/8 9:23
# @Author  : TangZhongZheng
# @File    : level.py
# @Description :
import pygame.display

from src.overlay import OverLay
from src.player import Player


class Level:
    def __init__(self):
        # 获取主屏幕的surface
        self.overlay = None
        self.player = None
        self.display_surface = pygame.display.get_surface()
        # 创建组，用来管理sprite
        self.all_sprite = pygame.sprite.Group()
        # 加载设置
        self.setup()

    def setup(self):
        self.player = Player((640, 360), self.all_sprite)
        self.overlay = OverLay(self.player)

    def run(self, dt):
        # 设置背景颜色
        self.display_surface.fill("pink")
        # 将组内的所有sprite绘制在surface
        self.all_sprite.draw(self.display_surface)
        # 调用所有的sprite方法
        self.all_sprite.update(dt)
        # 显示界面
        self.overlay.display()
